﻿namespace Services.Implement;

/// <summary>
/// 操作日志服务
/// </summary>
public class OperationLogBLL(ISqlSugarClient db) : BaseBLL<OperationLogVM>(db), IOperationLogBLL
{
    private readonly ISqlSugarClient _db = db;
    /// <summary>
    /// 操作日志列表分页
    /// </summary>
    /// <returns></returns>
    public async Task<List<OperationLogVM>> QueryPageListAsync(OperationLogPageQueryRM pageQueryRM, RefAsync<int> total)
    {
        var result = new List<OperationLogVM>();

        var list = await ALOGSData.GetQueryLogPage(pageQueryRM.Account, pageQueryRM.Name, pageQueryRM.Content, Convert.ToDateTime(pageQueryRM.OperateTimeStart).ToString("yyyy-MM-dd HH:mm:ss"),
        Convert.ToDateTime(pageQueryRM.OperateTimeEnd).ToString("yyyy-MM-dd HH:mm:ss"), pageQueryRM.PageIndex, pageQueryRM.PageSize, total);
        foreach (var item in list)
        {
            var log = new OperationLogVM();
            log.Account = item.Account;
            log.Name = item.Name;
            log.Content = item.Content;
            log.OperateTime = Convert.ToDateTime(item.Time);
            log.RoleName = item.RoleName;
            result.Add(log);
        }
        return result;
    }

}